using System.IO;
using System.Reflection;
using System.Text;
using Jurassic;

namespace Kiwi.Node.Modules
{
    public class EmbeddedScriptSource: FileScriptSource
    {
        public string ResourceName { get; private set; }

        public EmbeddedScriptSource(string resourceName) : base("resource:"+resourceName, Encoding.UTF8)
        {
            ResourceName = resourceName;
        }

        public override TextReader GetReader()
        {
            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName);
            return new StreamReader(stream);
        }
    }
}